package cn.tianya.irock.data.model;

import java.text.MessageFormat;

public class SearchQuery {
	
	public String getField() {
		return field;
	}

	public void setField(String filed) {
		this.field = filed;
	}

	public Object getValue() {
		return value;
	}

	public void setValue(String value) {
		this.value = value;
	}

	public static String LIKE = "like";
	public static String EQUALS = "=";
	public static String AND = "AND";
	public static String OR = "OR";
	
	private String field;
	private Object value;
	private String operate;
	private String term;
	
	
	public SearchQuery(String field, Object value) {
		this(field, value, SearchQuery.LIKE);
	}
	
	public SearchQuery(String filed, Object value, String operate) {
		this(filed, value, operate, SearchQuery.OR);
	}
	
	public SearchQuery(String field, Object value, String operate, String term) {
		this.field = field;
		this.value = value;
		this.operate = operate;
		this.term = term;
	}
	
	public String getOperate() {
		return operate;
	}
	public void setOperate(String operate) {
		this.operate = operate;
	}
	public String getTerm() {
		return term;
	}
	public void setTerm(String term) {
		this.term = term;
	}
	
	@Override
	public String toString() {
		//
		return MessageFormat.format("{0} {1} ? {2}", this.field, this.operate, this.term);
	}
}
